<?php
namespace builder;

//具体建造者：轿车
class CarBuilder implements BuilderInterface
{
    private $_car;

    public function createVehicle()
    {
        $this->_car = new Car();
    }

    public function addEngine()
    {
        $this->_car->setPart('carEngine', new Engine());
    }

    public function addWheel() //卡车是6个轮子，轿车是4个轮子，组装是有差异的
    {
        $this->_car->setPart('wheel1', new Wheel());
        $this->_car->setPart('wheel2', new Wheel());
        $this->_car->setPart('wheel3', new Wheel());
        $this->_car->setPart('wheel4', new Wheel());
    }   

    public function addDoors()
    {
        $this->_car->setPart('leftDoor', new Door());
        $this->_car->setPart('rightDoor', new Door());
    }

    public function getVehicle() : Vehicle
    {
        return $this->_car;
    }
   
}